package VWorldGameStudio;

import java.io.Serializable;

/**
 * 游戏的日期系统
 */
public class FCDate implements Serializable {
	// 游戏一年共12个月
	private static final int MONTH_OF_YEAR = 12;
	// 一个月共28天
	private static final int DAY_OF_MONTH = 28;
	// 一天为24小时
	private static final int HOUT_OF_DAY = 24;
	// 一小时为现实60秒
	private static final int SECOND_OF_HOUR = 60;
	// 当前年份
	private int nowYear;
	// 当前月份
	private int nowMonth;
	// 当前日期
	private int nowDay;
	// 当前小时
	private int nowHour;
	// 当前计时器
	private int nowSecond;

	/**
	 * 设置时间与日期
	 * 
	 * @param year
	 * @param month
	 * @param day
	 * @param hour
	 * @param second
	 */
	public void setDate(int year, int month, int day, int hour, int second) {
		this.nowDay = day;
		this.nowHour = hour;
		this.nowMonth = month;
		this.nowYear = year;
		this.nowSecond = second;
	}

	/**
	 * 计算时间，加一秒
	 */
	public void addOneSecond() {
		nowSecond++;
		if (nowSecond >= SECOND_OF_HOUR) {
			nowSecond = 0;
			nowHour++;
			if (nowHour >= HOUT_OF_DAY) {
				nowHour = 1;
				nowDay++;
				if (nowDay >= DAY_OF_MONTH) {
					nowDay = 1;
					nowMonth++;
					if (nowMonth >= MONTH_OF_YEAR) {
						nowMonth = 1;
						nowYear++;
					}
				}
			}
		}
	}

	/**
	 * 获取当前日期
	 * 
	 * @return
	 */
	public String getDateForString() {
		return nowYear + "Y" + nowMonth + "M" + nowDay + "D";
	}

	/**
	 * 获取当前日期
	 * 
	 * @return
	 */
	public String getDateForStringGame() {
		return nowYear + "年" + nowMonth + "月" + nowDay + "日";
	}

	/**
	 * 获取当前时间
	 * 
	 * @return
	 */
	public String getTimeForString() {
		return nowHour + ":" + nowSecond;
	}

	public int getNowyear() {
		return nowYear;
	}

	public int getNowmonth() {
		return nowMonth;
	}

	public int getNowday() {
		return nowDay;
	}

	public int getNowhour() {
		return nowHour;
	}

	public int getNowsecond() {
		return nowSecond;
	}

	public void setsaveYear(String year) {
		this.nowYear = Integer.valueOf(year);
	}

	public void setsaveMonth(String month) {
		this.nowMonth = Integer.valueOf(month);
	}

	public void setsaveDay(String day) {
		this.nowDay = Integer.valueOf(day);
	}

	public void setsaveHour(String hour) {
		this.nowHour = Integer.valueOf(hour);
	}

	public void setsaveSecond(String second) {
		this.nowSecond = Integer.valueOf(second);
	}
}
